package com.zego.wawaji.ui.wawa.synth.gallery;

import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.zego.wawaji.R;
import com.zego.wawaji.third.image.ImageLoader;
import com.zego.wawaji.ui.bean.wawa.Wawa;
import com.zego.wawaji.wawaji_client.AppTinkerLike;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by jameson on 8/30/16.
 */
class CardAdapter extends RecyclerView.Adapter<CardAdapter.ViewHolder> {
    private List<Wawa> mList = new ArrayList<>();

    public CardAdapter(List<Wawa> mList) {
        this.mList = mList;
    }

    @Override
    public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View itemView = LayoutInflater.from(parent.getContext()).inflate(R.layout.view_card_item, parent, false);
        return new ViewHolder(itemView);
    }

    @Override
    public void onBindViewHolder(final ViewHolder holder, final int position) {
        Wawa wawa = mList.get(position);
        ImageLoader.loadCenterCrop(AppTinkerLike.getContext(), wawa.getBigImg(), holder.mImageView);
        holder.name.setText(wawa.getName());
//        String tips = wawa.getRemark();
//        if (!TextUtils.isEmpty(tips)) {
//            holder.remark.setText(tips);
//        }
    }

    @Override
    public int getItemCount() {
        return mList.size();
    }

    public class ViewHolder extends RecyclerView.ViewHolder {
        public final ImageView mImageView;
        private TextView name, remark;

        public ViewHolder(final View itemView) {
            super(itemView);
            mImageView = (ImageView) itemView.findViewById(R.id.iv_gallery);
            name = (TextView) itemView.findViewById(R.id.name);
            remark = (TextView) itemView.findViewById(R.id.remark);
        }
    }
}
